/*
 * Copyright 2018-present KunMinX
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.nsgf.library.ui.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;

import androidx.recyclerview.widget.RecyclerView;

import com.kunminx.binding_recyclerview.adapter.SimpleDataBindingAdapter;
import com.nsgf.library.R;
import com.nsgf.library.data.bean.LibraryInfo;
import com.nsgf.library.databinding.ItemNsgfPatrolFeedBinding;
import com.nsgf.library.ui.workbenches.PatrolAbnormalActivity;
import com.nsgf.library.ui.workbenches.PatrolFeedActivity;

/**
 * Create by GC at 24/10/19
 */
public class PatrolFeedListAdapter extends SimpleDataBindingAdapter<LibraryInfo, ItemNsgfPatrolFeedBinding> {

    public PatrolFeedListAdapter(Context context) {
        super(context, R.layout.item_nsgf_patrol_feed, DiffUtils.getInstance().getLibraryInfoItemCallback());

    }

    @Override
    protected void onBindItem(ItemNsgfPatrolFeedBinding binding, LibraryInfo item, RecyclerView.ViewHolder holder) {

        binding.setVm(item);


        binding.llItemWork.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mContext.startActivity(new Intent()
                        .putExtra("title", "未巡水库")
                        .putExtra("date", item.getInspectDate())
                        .putExtra("type", "0")
                        .setClass(mContext, PatrolAbnormalActivity.class));
            }
        });
        binding.llItemAbnormal.setOnClickListener(view -> mContext.startActivity(new Intent()
                .putExtra("title", "水库问题")
                .putExtra("date", item.getInspectDate())
                .putExtra("type", "1")
                .setClass(mContext, PatrolAbnormalActivity.class)));

    }
}
